package File;
import java.io.FileFilter;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;

public class Test {

    public static void main(String[] args) throws IOException {
        /*
        //6
        //(2)
        File dir = new File(".");
        if (dir.isDirectory()){
            File[] sub = dir.listFiles(new FileFilter() {
                public boolean accept(File file) {
                    return file.getName().contains("s");
                }
            });
            for (File a : sub){
                System.out.println(a.getName());
            }
        }


        //(1)
        File dir = new File(".");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles(file->file.getName().contains("s"));
            for (File sub :subs){
                System.out.println(sub.getName());
            }
        }


         */














        //4.
        /*
        Scanner scan = new Scanner(System.in);
        while (true){

        System.out.println("请输入文件名");
        String name = scan.next();
        File x = new File(name);

            if (x.exists()) {
                System.out.println("文件已存在请更改");

            } else {
                x.mkdir();
                System.out.println("该目录已创建");
                return;

            }
        }


         */
        //4.
        /*
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入文件名");
        String name = scan.next();
        File f = new File(name);
        if (f.exists()){
            f.delete();
            System.out.println("该文件或目录已删除");

        }else {
            System.out.println("该文件或目录不存在");
        }

         */








        //3.
        /*
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入文件名");
        String name = scan.next();
        File dir = new File(name);
        if (dir.exists()){
            System.out.println("该目录已存在");
        }else {
            dir.mkdir();
            System.out.println("该目录已创建");
        }


         */



        //2.
        /*
        File f = new File("./test.txt");
        if (f.exists()){
            f.delete();
            System.out.println("该文件已删除");
        }else {
            System.out.println("该文件不存在");
        }

         */






        //1.
    /*
        for (int i=1;i<=100;i++){
            File file = new File("./test"+i+".txt");
            if (!file.exists()){
                file.createNewFile();
            }
        }
        System.out.println("创建完毕！");
   */







        //6
        /*
        File dir = new File(".");
        if (dir.isDirectory()){
            File[] sub = dir.listFiles(new FileFilter() {
                public boolean accept(File file) {
                    return file.getName().contains("s");
                }
            });
            for (File a : sub){
                System.out.println(a.getName());
            }
        }


         */


        /*
        File dir = new File(".");
        if (dir.isDirectory()){
            File[] subs = dir.listFiles(file->file.getName().contains("s"));
            for (File sub :subs){
                System.out.println(sub.getName());
            }
        }

         */













        //4.
        /*
        Scanner scan = new Scanner(System.in);
        while (true){

        System.out.println("请输入文件名");
        String name = scan.next();
        File x = new File(name);

            if (x.exists()) {
                System.out.println("文件已存在请更改");

            } else {
                x.mkdir();
                System.out.println("该目录已创建");
                return;

            }
        }


         */
        //4.
        /*
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入文件名");
        String name = scan.next();
        File f = new File(name);
        if (f.exists()){
            f.delete();
            System.out.println("该文件或目录已删除");

        }else {
            System.out.println("该文件或目录不存在");
        }

         */








        //3.
        /*
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入文件名");
        String name = scan.next();
        File dir = new File(name);
        if (dir.exists()){
            System.out.println("该目录已存在");
        }else {
            dir.mkdir();
            System.out.println("该目录已创建");
        }


         */



        //2.
        /*
        File f = new File("./test.txt");
        if (f.exists()){
            f.delete();
            System.out.println("该文件已删除");
        }else {
            System.out.println("该文件不存在");
        }

         */






    //1.
    /*
        for (int i=1;i<=100;i++){
            File file = new File("./test"+i+".txt");
            if (!file.exists()){
                file.createNewFile();
            }
        }
        System.out.println("创建完毕！");
   */

     }
}
